/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import Model.Simulacion;
import Principals.Main;
import java.util.Date;
import java.util.List;
import org.hibernate.Query;
            

/**
 *
 * @author sebastian
 */
public class SimulacionDAO {
    
    public static Simulacion registrarSimulacion(Simulacion objSimulacion){
        Main.usrSesion.session.beginTransaction();
        Main.usrSesion.session.save(objSimulacion);
        Main.usrSesion.session.getTransaction().commit();
        return objSimulacion ;
    }
    
       public static List<Simulacion> buscarLog(Date fechaInicio,Date fechaFin ) {
        String q = "from Simulacion ";
        int cont = 0;
           q += " where fecha_inicio between date_trunc('day', cast(:fechaInicio as timestamp))  and date_trunc('day', cast(:fechaFin  as timestamp))";
        
      
        Main.usrSesion.session.beginTransaction();
        Query query = Main.usrSesion.session.createQuery(q);
        
            query.setParameter("fechaInicio", fechaInicio);
            query.setParameter("fechaFin", fechaFin);
        
        Main.usrSesion.session.getTransaction().commit();

        return query.list();
    }

}
